<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="../assets/js/vue.js"></script>
    <title>v-on 实例!</title>
</head>

<body>
    <h1>v-on 实例!</h1>
    <hr>
    <div id="app">
      <h4>本场比赛分数: {{score}}</h4>
      <button @click="add">加分</button>
      <button v-on:click="reduce">减分</button>
      <input type="text" v-on:keyup.enter="onEnter" v-model="score2">
    </div>

    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                score:0,
                score2:1
            },
            methods:{
                add:function(){
                    this.score++;
                },
                reduce:function(){
                    this.score--;
                },
                onEnter:function(){
                    this.score = this.score + parseInt(this.score2);
                }
            }
        })
    </script>
</body>

</html>